import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @program: LeetCode
 * @description: LeetCode : 6347. 统计范围内的元音字符串数
 * @author: WXY
 * @create: 2023-02-05 10:47
 * @Version 1.0
 **/
public class Num6347_vowelStrings {
    public static int[] vowelStrings(String[] words, int[][] queries) {
        List<Integer> list = new ArrayList<>();
        Set<Character> set = new HashSet<>();
        set.add('a');
        set.add('e');
        set.add('i');
        set.add('o');
        set.add('u');
        int len = words.length;
        int[] a = new int[len + 1];
        for (int i = 0, j = 1; i < len; i++, j++) {
            String s = words[i];
            char fir = s.charAt(0);
            char lst = s.charAt(s.length() - 1);
            if (set.contains(fir) && set.contains(lst)) {
                a[j]++;
            }
        }
        for (int i = 1; i <=len; i++) a[i] = a[i - 1] + a[i];
        for (int[] arr : queries) {
            int l = arr[0] + 1;
            int r = arr[1] + 1;
            list.add(a[r] - a[l-1]);
        }
        int[] ans = new int[list.size()];
        int index = 0;
        for (int n : list) {
            ans[index++] = n;
        }
        return ans;
    }

    public static void main(String[] args) {
        String[] strings = {"a", "e", "i"};
        int[][] arr = {{0, 2}, {0,1}, {2, 2}};
        int[] ans = vowelStrings(strings, arr);
        for (int i : ans) {
            System.out.print(i + " ");
        }
    }
}
